package com.webemail.sys.util;

import com.webemail.sys.model.SysEmailAccount;

public class MailUtils {
	public static MailBean getReMailBean(SysEmailAccount sysEmailAccount) {
		MailBean re = null;
		if (sysEmailAccount == null) {
			return null;
		}
		if (sysEmailAccount.getMailType().trim().equals("1")) {
			re = MailProperties.getQQMailBean(sysEmailAccount.isPOP3(), sysEmailAccount.isSSL());
			re.setHost(sysEmailAccount.getHost());
			re.setPort(sysEmailAccount.getPort());
			re.setSocketFactoryPort(sysEmailAccount.getPort());
		} else {
			switch (sysEmailAccount.getMailType().trim()) {
			
			case "QQ":
				re = MailProperties.getQQMailBean(sysEmailAccount.isPOP3(), sysEmailAccount.isSSL());
				break;
			case "aliyun":
				re = MailProperties.getALIMailBean(sysEmailAccount.isPOP3(), sysEmailAccount.isSSL());
				break;
			case "yahoo":
				re = MailProperties.getYaHooMailBean(sysEmailAccount.isPOP3(), sysEmailAccount.isSSL());
				break;
			case "exQQ":
				re = MailProperties.getEXQQMailBean(sysEmailAccount.isPOP3(), sysEmailAccount.isSSL());
				break;
			case "gmail":
				re = MailProperties.getGoogleMailBean(sysEmailAccount.isPOP3(), sysEmailAccount.isSSL());
				break;
			}
		}
		re.setAccount(sysEmailAccount.getAccount());
		re.setPassword(sysEmailAccount.getPassword());
		return re;
	}
	public static MailBean getLsReMailBean(SysEmailAccount sysEmailAccount) {
		MailBean re = null;
		if (sysEmailAccount == null) {
			return null;
		}

		re = MailProperties.getLsIMailBean(sysEmailAccount.isSSL());
		re.setHost(sysEmailAccount.getHost());
		re.setPort(sysEmailAccount.getPort());
		re.setSocketFactoryPort(sysEmailAccount.getPort());

		re.setAccount(sysEmailAccount.getAccount());
		re.setPassword(sysEmailAccount.getPassword());
		return re;
	}

	public static MailBean getSendMailBean(SysEmailAccount sysEmailAccount) {
		MailBean send = null;
		if (sysEmailAccount == null) {
			return null;
		}
		if (sysEmailAccount.getMailType().trim().equals("1")) {
			send = MailProperties.getQQMailBean(sysEmailAccount.isSSL());
			send.setHost(sysEmailAccount.getSendHost());
			send.setPort(sysEmailAccount.getSendPort());
			send.setSocketFactoryPort(sysEmailAccount.getSendPort());

		} else {
			switch (sysEmailAccount.getMailType().trim()) {
			case "163":
				send = MailProperties.get163MailBean(sysEmailAccount.isSSL());
				break;
			case "QQ":
				send = MailProperties.getQQMailBean(sysEmailAccount.isSSL());
				break;
			case "aliyun":
				send = MailProperties.getALIMailBean(sysEmailAccount.isSSL());
				break;
			case "yahoo":
				send = MailProperties.getYaHooMailBean(sysEmailAccount.isSSL());
				break;
			case "exQQ":
				send = MailProperties.getEXQQMailBean(sysEmailAccount.isSSL());
				break;
			case "gmail":
				send = MailProperties.getGoogleMailBean(sysEmailAccount.isSSL());
				break;
			}
		}
		send.setAccount(sysEmailAccount.getAccount());
		send.setPassword(sysEmailAccount.getPassword());
		return send;
	}
	public static MailBean getLsSendMailBean(SysEmailAccount sysEmailAccount) {
		MailBean send = null;
		if (sysEmailAccount == null) {
			return null;
		}
		send = MailProperties.getLsIMailBean(sysEmailAccount.isSSL());
		send.setHost(sysEmailAccount.getSendHost());
		send.setPort(sysEmailAccount.getSendPort());
		send.setSocketFactoryPort(sysEmailAccount.getSendPort());

		send.setAccount(sysEmailAccount.getAccount());
		send.setPassword(sysEmailAccount.getPassword());
		return send;
	}
}
